
use std::collections::HashMap;

pub fn return_median(nums:&mut Vec<i32>) -> (i32,i32){
    if nums.len() == 0 {
        return  (0,0);
    }
    nums.sort();

    let mut nums_map = HashMap::new();
    for val in nums.iter() {
        let count = nums_map.entry(val).or_insert(0);
        *count += 1;
    }
    let mut mode_num = nums[0];
    for (key,val) in nums_map.clone().into_iter() {
        if val > mode_num {
            mode_num = *key
        }
    }
    println!("map {:?}",nums_map);
    println!("nums len {:?}",nums);
    if nums.len() % 2 != 0 {
        (nums[nums.len() / 2],mode_num)
    }else {
        let n = dbg!(nums.len() / 2);
        ((dbg!(nums[n]) + dbg!(nums[n - 1])) / 2,mode_num)
    }
}